import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-08
 * Time: 20:43
 */
public class Test43 {

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val,TreeNode left,TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    static long pre = Integer.MIN_VALUE;
    public static boolean isValidBST(TreeNode root) {
        if(root == null) {
            return true;
        }
        boolean left = isValidBST(root.left);
        boolean cur = false;
        if(pre < root.val) {
            cur = true;
        }
        pre = root.val;
        boolean right = isValidBST(root.right);
        return left && right && cur;
    }

    public static TreeNode build(String s) {
        String input = s.replace("[","");
        input = input.replace("]","");
        String[] part = input.split(",");
        Integer[] num = new Integer[part.length];

        for(int i = 0; i < part.length;i++) {
            if(!part[i].equals("null")) {
                num[i] = Integer.parseInt(part[i]);
            }else {
                num[i] = null;
            }
        }
        TreeNode root = new TreeNode(num[0]);
        Queue<TreeNode> q = new LinkedList<>();
        q.offer(root);
        int index = 1;
        while(!q.isEmpty() && index < num.length) {
            TreeNode cur = q.poll();
            if(num[index] != null && index < num.length) {
                cur.left = new TreeNode(num[index]);
                q.offer(cur.left);
            }
            index++;
            if(num[index] != null && index < num.length) {
                cur.right = new TreeNode(num[index]);
                q.offer(cur.right);
            }
            index++;
        }
        return root;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        TreeNode root = build(s);
        boolean ret = isValidBST(root);
        System.out.println(ret);
    }
}
